package com.ruoyi.framework.Sms;

import com.ruoyi.common.constant.Constants;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.ServletWebRequest;

/**
 * @Author laohei
 * @Date 2020/11/3 10:07
 * @Version 1.0
 */
// 短信验证码生成器
@Component("smsCodeGenerator")
public class SmsCodeGenerator implements ValidateCodeGenerator {

    @Override
    public ValidateCode generate(ServletWebRequest request) {
        String code = RandomStringUtils.randomNumeric(Constants.SMS_RANDOM_SIZE);
        return new ValidateCode(code, Constants.SMS_EXPIRE_SECOND);
    }

}
